#!/usr/bin/env julia
using DelimitedFiles
using Printf

rows = readdlm("results/drp4dvar_vs_3dvar/metrics_aggregated.csv", ',', header=true)[1]
open("results/drp4dvar_vs_3dvar/drp_summary.md", "w") do io
    println(io, "| Timestamp | Ensemble | Cost | RMS Innov | |Δx| | Solve Time (s) |")
    println(io, "|-----------|----------|------|-----------|------|----------------|")
    for row in eachrow(rows)
        method = String(row[2])
        method != "drp4dvar" && continue
        ts = String(row[1])
        cost = row[3]
        rms = row[4]
        dx = row[5]
        time = row[6]
        ens = Int(round(row[7]))
        @printf(io, "| %s | %d | %.3f | %.4f | %.3f | %.3f |\n", ts, ens, cost, rms, dx, time)
    end
end
println("Wrote summary table")
